package com.choosefine.devops.dms.system.pages.controller;

import com.choosefine.devops.dms.base.BaseController;
import com.choosefine.devops.dms.system.pages.Menu;
import com.choosefine.devops.dms.system.pages.service.IndexService;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.io.IOException;
import java.util.Map;

/**
 * Created by 邱鹏 on 2017/3/2.
 */
@Controller
@Slf4j
public class IndexController extends BaseController{
    @Autowired
    IndexService indexService;

    @GetMapping("/devops/dms/index.html")//这个是当前的url特有的url部分
    public ModelAndView index() throws IOException {//ModelAndView就是返回模板和视图
        ModelAndView view = new ModelAndView("/devops/dms/index.btl");
        Map modelMap = indexService.index();
        view.addAllObjects(modelMap);
        return view;
    }
    
    @PostMapping("/addIndex")
    @ApiOperation(value = "新增菜单", notes = "新增菜单")
    public String addIndex(@RequestBody Menu menu){
    	indexService.addIndex(menu);
    	return responseSuccess(menu);
    }
}
